package com.jinxin.platform.cdacsrecord.core.controller;

import com.jinxin.platform.cdacsrecord.core.service.AcsControlModuleInvokeService;
import com.jinxin.platform.cdacsrecord.core.service.AcsControlModuleRegService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.HashMap;

/**
 * Description: apcos-acs-all
 * Created by 34759 on 2020/4/6 9:58
 */
@RestController
//@RequestMapping("/")
@Slf4j
public class LoginController {
    @Autowired
    private AcsControlModuleInvokeService invokeService;
    @Autowired
    private AcsControlModuleRegService moduleRegService;

//    @GetMapping("/")
//    public ModelAndView toIndex(){
//        return new ModelAndView("menu/menu","accountInfo","admin" );
//    }

    @GetMapping("/test")
    public String testInvoke(){
        return invokeService.getLoginUserInfo();
    }

    @GetMapping("/testSelAcsUser")
    public String testSelAcsUser(String uid){
        HashMap<Object, Object> hashMap = new HashMap();
        if(!StringUtils.isEmpty(uid)){
            hashMap.put("acsUID",uid );
        }
        return moduleRegService.selAcsUserInfoById(hashMap).toString();
    }

    //添加开门记录
    //http://localhost:20012/testAddAcsOpenLog?deviceName=test1&deviceId=11&deviceMainBody=物业机01&deviceMainBodyId=112&mainBodyIdentity=大门1
    //添加通话记录
    //http://localhost:20012/testAddAcsCallLog?deviceName=test1&deviceId=11&deviceMainBody=物业机01&deviceMainBodyId=11&taikDuration=20
    //添加随机二维码3 数字4 5人脸
    //http://localhost:20012/testAddAcsCodeLog?operatorId=1234&operatorName=测试01&visitorName=访客01&recordInfo=2894&type=3

    @GetMapping("/testAddAcsOpenLog")
    public String testAddAcsOpenLog(String deviceName,String deviceId, String deviceMainBody,
                                    String deviceMainBodyId,String mainBodyIdentity){
        HashMap<Object, Object> hashMap = new HashMap();
        if(!StringUtils.isEmpty(deviceName)){
            hashMap.put("deviceName",deviceName );
        }
        if(!StringUtils.isEmpty(deviceId)){
            hashMap.put("deviceId",deviceId );
        }
        if(!StringUtils.isEmpty(deviceMainBody)){
            hashMap.put("deviceMainBody",deviceMainBody );
        }
        if(!StringUtils.isEmpty(deviceMainBodyId)){
            hashMap.put("deviceMainBodyId",deviceMainBodyId );
        }
        if(!StringUtils.isEmpty(mainBodyIdentity)){
            hashMap.put("mainBodyIdentity",mainBodyIdentity );
        }
        return moduleRegService.addAcsOpenDoorLogInfo(hashMap).toString();
    }

    @GetMapping("/testAddAcsCallLog")
    public String testAddAcsCallLog(String deviceName,String deviceId, String deviceMainBody,
                                    String deviceMainBodyId,String taikDuration){
        HashMap<Object, Object> hashMap = new HashMap();
        if(!StringUtils.isEmpty(deviceName)){
            hashMap.put("deviceName",deviceName );
        }
        if(!StringUtils.isEmpty(deviceId)){
            hashMap.put("deviceId",deviceId );
        }
        if(!StringUtils.isEmpty(deviceMainBody)){
            hashMap.put("deviceMainBody",deviceMainBody );
        }
        if(!StringUtils.isEmpty(deviceMainBodyId)){
            hashMap.put("deviceMainBodyId",deviceMainBodyId );
        }
        if(!StringUtils.isEmpty(taikDuration)){
            hashMap.put("taikDuration",taikDuration );
        }
        hashMap.put("createTime", LocalDateTime.now());
        hashMap.put("listenedTime",LocalDateTime.now());
        return moduleRegService.addAcsCallLogInfo(hashMap).toString();
    }


    @GetMapping("/testAddAcsCodeLog")
    public String testAddAcsCodeLog( String operatorId, String operatorName,
                                    String visitorName,String recordInfo,String type){
        HashMap<Object, Object> hashMap = new HashMap();
//        if(!StringUtils.isEmpty(operatorId)){
//            hashMap.put("operatorId",operatorId );
//        }
//        if(!StringUtils.isEmpty(operatorName)){
//            hashMap.put("operatorName",operatorName );
//        }
//        if(!StringUtils.isEmpty(visitorName)){
//            hashMap.put("visitorName",visitorName );
//        }
//        if(!StringUtils.isEmpty(recordInfo)){
//            hashMap.put("recordInfo",recordInfo );
//        }
//        hashMap.put("createTime", LocalDateTime.now());
//        if(StringUtils.isEmpty(type)|| type.equals("3") ){
//            return moduleRegService.addAcsVisCodeLogInfo(hashMap).toString();
//        }
//        if( type.equals("4") ){
//            return moduleRegService.addAcsVisNumLogInfo(hashMap).toString();
//        }
//        if( type.equals("5") ){
//            return moduleRegService.addAcsVisFaceLogInfo(hashMap).toString();
//        }
        return moduleRegService.addAcsVisCodeLogInfo(hashMap).toString();
    }



}
